import { Body, Controller, Post, UseFilters, UseGuards } from '@nestjs/common';
import { AuthService } from './auth.service';
import { TypeormFilter } from '../filters/typeorm.filter';
import { SigninDto } from './dto/signinDto';
import { JwtGuard } from '../guards/jwt.guard';

@Controller('auth')
@UseFilters(new TypeormFilter())
export class AuthController {
  constructor(private authService: AuthService) {
  }

  @Post('/signin')
  async signin(@Body() dto:SigninDto) {
    const {username,password}=dto;
    const token= await this.authService.signin(username,password);
    return {
      access_tokens:token
    }
   }

  @Post('/signup')
  signup(@Body() dto:SigninDto) {
    const {username,password}=dto;
    return this.authService.signup(username,password)
  }
}
